def count_sort(array):
    bottom=min(array)
    top=max(array)
    area=top-bottom+1
    counts=[0]*area
    for n in array:
        counts[n-bottom]+=1
    p=0
    for i in range(area):
        for j in range(counts[i]):
            array[p]=i+bottom
            p+=1

array=[4,2,2,8,3,3,1]
print(array)
count_sort(array)
print(array)
